﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.DataAccess;
using System.Collections.ObjectModel;
using University.Workshop.Model;

namespace University.Workshop.Business
{
    public static class ViewProductManager
    {
        public static Collection<Product> GridLoad()
        {
            return ProductDataAccess.ViewAllProductsOnSale();
        }
        public static object LoadCompleteInformation(string id)
        {
            return ProductDataAccess.DescriptionProduct(id);
        }
        /*public static string[] splitString(string word)
        {
            string[] wordList = null;
            if (word != null)
            {
                wordList = word.Split(' ');
            }
            return wordList;
        }*/

        public static void PageViewed(string userId, string prodId)
        {
            DateTime date = DateTime.Now;
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(prodId))
            {
                throw new BusinessException("Incorrect method call at view");
            }
            else
            {
                ViewsDataAccess.InsertView(userId, prodId, date);
            }
        }
    }
}
